<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">演示</a>
        <a>
          <cite>导航元素</cite></a>
      </span>
	<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
		<i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
	<div class="layui-row">
		<form class="layui-form layui-col-md12 x-so">
			<input type="text" name="nickname" value="{:input('nickname')}"  placeholder="请输入用户名" autocomplete="off" class="layui-input">
			<button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
		</form>
	</div>
	<xblock>
		<button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量恢复</button>
		<span class="x-right" style="line-height:40px">共有数据：{$users->total()} 条</span>
	</xblock>
	<table class="layui-table">
		<thead>
		<tr>
			<th>
				<div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
			</th>
			<th>ID</th>
			<th>用户名</th>
			<th>性别</th>
			<th>手机</th>
			<th>邮箱</th>
			<th>地址</th>
			<th>账号状态</th>
			<th>加入时间</th>
			<th>目前状态</th>
			<th>操作</th>
		</thead>
		<tbody>
		{volist name='$users' id='user'}
		<tr>
			<td>
				<div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='{$user.user_id}'><i class="layui-icon">&#xe605;</i></div>
			</td>
			<td>{:$user.user_id}</td>
			<td>{:$user.nickname}</td>
			<td>{:$user.sex==1 ? '女' :'男'}</td>
			<td>{:$user.phone}</td>
			<td>{:$user.email}</td>
			<td>{:$user.city}</td>
			<td class="td-status">
				{if condition='$user.static==0'}
				<span class="layui-btn layui-btn-normal layui-btn-mini">已启用</span>
				{else if/}
				<span class="layui-btn layui-btn-normal layui-btn-mini layui-btn-disabled">已禁用</span>
				{/if}
			</td>
			<td>{:$user.create_time}</td>
			<td class="td-status">
              <span class="layui-btn layui-btn-danger layui-btn-mini">
                                已删除
                            </span>
			<td class="td-manage">
				<a title="恢复" onclick="member_recover(this,{$user.user_id})" href="javascript:;">
					<i class="layui-icon">&#xe618;</i>
				</a>
				<a title="彻底删除" onclick="member_del(this,{$user.user_id})" href="javascript:;">
					<i class="layui-icon">&#xe640;</i>
				</a>
			</td>
		</tr>
		{/volist}
		</tbody>
	</table>
	<div class="page">
		{$users->render()}
	</div>

</div>
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });
        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });
    /*用户-删除*/
    function member_del(obj,id){
        layer.confirm('确认彻底删除该用户吗？',function(index){
            //发异步删除数据
			$.post("{:url('admin/Del/delTrue')}", {user_id: id}, function(res, textStatus, xhr) {
                if (res.code == 0) {
                    layer.msg(res.msg, function () {
                    });
                } else {
                    layer.alert(res.msg, function () {
                        location.reload();
                    })
                }
			});
        });
    }

    function member_recover(obj,id){
        layer.confirm('确定恢复该用户吗？',function(index){
            //发异步删除数据
            $.post("{:url('admin/Del/recover')}", {user_id: id}, function(res, textStatus, xhr) {
                if (res.code == 0) {
                    layer.msg(res.msg, function () {
                    });
                } else {
                    layer.alert(res.msg, function () {
                        location.reload();
                    })
                }
            });
        });
    }

    function delAll (argument) {
        var data = tableCheck.getData();
        layer.confirm('确认要恢复吗？',function(index){
            //捉到所有被选中的，发异步进行删除
            $.post("{:url('admin/Del/recoverAll')}", {user_id: data}, function(res, textStatus, xhr) {
                if (res.code == 0) {
                    layer.msg(res.msg, function () {
                    });
                } else {
                    layer.alert(res.msg, function () {
                        location.reload();
                    })
                }
            });
        });
    }
</script>
</body>
